//回车提交
$(document).keypress(function (e) {
    // 回车键事件  
    if (e.which == 13) {
        $(".btn").click();
    }
});

function login_check() {
    var user_name = $('#username').val();
    var pass_word = $('#password').val();
    if (!user_name || !pass_word) {
        l_fail('用户名或密码不能为空');
        return false;
    } else {
        var da = new Object();
        da.user_name = user_name;
        da.pass_word = pass_word;
        login(JSON.stringify(da));
    }
}

/*登录*/
function login(pa) {
    var url = '?m=index-Index&do=login';
    var data = {
        data: pa
    };
    $.ajax({
        url: url,
        type: 'post',
        dataType: 'json',
        data: data,
        success: function (res) {
//            console.log(res);
            if (res.code == 200)
            {
                var red_url = "?m=index-Order&do=add";
                redir_url(red_url);
            } else
            {
                l_fail(res.message);
            }
        }
    });
}

